#!/bin/bash
source /etc/profile
if [ -n "$1" ] ;then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
drop table test.tmp_rollback;
create table test.tmp_rollback as
select shopId , userId, areaId,shopName, shopLv, status,createTime, modifyTime , start_date, end_date, '1' as tag
from test.shop_his
where end_date < '$do_date'
union all
select shopId , userId, areaId,shopName, shopLv, status,createTime, modifyTime , start_date, '9999-12-31' as end_date, '2' as tag
from test.shop_his
where start_date <= '$do_date' and end_date >= '$do_date';
"
hive -e "$sql"
